<template>
	<cl-select-table
		v-model="value"
		:title="t('选择处方信息')"
		:service="service.appoint.prescription"
		:columns="columns"
		:multiple="multiple"
		:dict="{ text: 'doctorname' }"
		pickerType="text"
	/>
</template>

<script setup lang="ts">
defineOptions({
	name: "appoint-prescription-select",
});

import { useCool } from "/@/cool";
import { useI18n } from "vue-i18n";
import { CrudProps } from "/#/crud";
import { reactive, ref, useModel } from "vue";

const props = defineProps({
	...CrudProps,
	modelValue: null,
	multiple: Boolean,
});

const { service } = useCool();
const { t } = useI18n();

const value = useModel(props, "modelValue");

// 选项
const options = reactive({
	patientGender: [
		{ label: t("未知"), value: 0 },
		{ label: t("男"), value: 1 },
		{ label: t("女"), value: 2 },
	],
	prescriptionStatus: [
		{ label: t("待审核"), value: 0 },
		{ label: t("已审核"), value: 1 },
		{ label: t("已完成"), value: 2 },
		{ label: t("已取消"), value: 3 },
	],
});

const columns = ref([
	{ label: t("姓名"), prop: "sysDoctorName", minWidth: 140 },
	{ label: t("处方编号"), prop: "prescriptionNo", minWidth: 140 },
	{ label: t("患者姓名"), prop: "patientName", minWidth: 140 },
	{
		label: t("患者性别"),
		prop: "patientGender",
		minWidth: 120,
		dict: options.patientGender,
	},
	{
		label: t("患者年龄"),
		prop: "patientAge",
		minWidth: 140,
		sortable: "custom",
	},
	{
		label: t("诊断结果"),
		prop: "diagnosisResult",
		showOverflowTooltip: true,
		minWidth: 200,
	},
	{ label: t("医生姓名"), prop: "doctorName", minWidth: 140 },
	{ label: t("医生科室"), prop: "doctorDepartment", minWidth: 140 },
	{
		label: t("处方日期"),
		prop: "prescriptionDate",
		minWidth: 140,
		sortable: "custom",
		component: { name: "cl-date-text", props: { format: "YYYY-MM-DD" } },
	},
	{
		label: t("处方状态"),
		prop: "prescriptionStatus",
		minWidth: 120,
		dict: options.prescriptionStatus,
	},
	{
		label: t("备注"),
		prop: "remark",
		showOverflowTooltip: true,
		minWidth: 200,
	},
]);
</script>
